/*
 *  Class name: JOptionDialogWindowHandler.java
 *  Version: 1.0
 *  Date: 13.12.2013
 */
package cz.muni.fi.pa165.soccergamesarchive.restclient.utils;

import java.awt.Component;
import javax.print.event.PrintJobEvent;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

import static javax.swing.JOptionPane.showConfirmDialog;
import static javax.swing.JOptionPane.showInputDialog;
import static javax.swing.JOptionPane.showMessageDialog;

/**
 *
 * @author Michal Ďuriš
 */
public class JOptionDialogWindowHandler {

    public JOptionDialogWindowHandler() {
    }

    public static void showErrorDialogWindow(Component parent, String title,
                                             String errorMessage) {

        showMessageDialog(parent, errorMessage, title,
                JOptionPane.ERROR_MESSAGE);
    }

    public static void showInfoDialogWindow(Component parent, String title,
                                            String infoMessage) {

        showMessageDialog(parent, infoMessage, title,
                JOptionPane.INFORMATION_MESSAGE);
    }

    public static int showCustomYesNoDialogWindow(Component parent, String title,
                                                  Object message) {

        return showConfirmDialog(parent, message, title,
                JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
    }

    public static int showYesNoDialogWindow(Component parent, String title,
                                            String questionMessage) {

        return showConfirmDialog(parent, questionMessage, title,
                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
    }

    public static Object showSelectBoxDialogWindow(Component parent,
                                                   String title,
                                                   String questionMessage,
                                                   Object[] selectionValues) {

        return showInputDialog(parent, questionMessage, title,
                JOptionPane.QUESTION_MESSAGE, null, selectionValues,
                selectionValues[0]);
    }

    public static String showInputDialogWindow(Component parent, String title,
                                               String inputDialogMessage,
                                               String input, ImageIcon icon) {

        return (String) showInputDialog(parent, inputDialogMessage,
                title, JOptionPane.QUESTION_MESSAGE, icon, null, input);
    }

}
